#ifndef BLOCKGROUP_H
#define BLOCKGROUP_H

#include "BlockLinkedList.h"

//This class represents BlockLinkedList obtained from a FreeList

//author: Sean

class BlockGroup: public BlockLinkedList {
friend class FreeList;
 public:

  /**
   *Initializes a new BlockGroup
   *param = bll	BlockLinkedList to use to initialize. 
   */
  BlockGroup(BlockLinkedList bll){


  }

  /**
   *param:
   * startBlock	is the starting block number of the BlockGroup.
   * endBlock	is the ending block number of the BlockGroup.
   * numberOfBlocks	is the number of blocks in this BlockGroup.
   * motherFreeList	is the BlockGroup's originating Free List.
   */
  BlockGroup(int startBlock, int endBlock, int numberOfBlocks, BlockLinkedList* motherFreeList){

      this->m_startBlockNumber = startBlock;
      this->m_endBlockNumber = endBlock;
      this->m_numberOfBlocks =  numberOfBlocks;
      this->m_motherFreeList = motherFreeList;
      this->m_disk = this->m_motherFreeList->getDisk();
      this->m_seek = NULL;
  }
  /**
   *Add another (empty) block to the end of this BlockGroup
   *return: true iff Block could be added
   */
  bool AddNewBlock(){
      Block* newBlock = this->m_motherFreeList->UnlinkBlock();
      if (this->AddBlock(newBlock)){
          this->m_endBlockNumber = newBlock->GetBlockNumber();
          this->m_numberOfBlocks++;
      }
      else return false;
  }

  /**
   *Sets the free list for the BlockGroup
   *param: motherFreeList  BlockLinkedList to be set
   */
  void SetFreeList(BlockLinkedList* motherFreeList){
      this->m_motherFreeList = motherFreeList;
  }

  

 protected:

  BlockLinkedList* m_motherFreeList;
};


#endif
